package com.qingcheng.controller;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Welcome to the most Amazing IntelliJ IIIDEA.
 * Creat0r: ^_^ fffantianxing ^_^
 * Date: 2019-07-25
 * Time: 18:45
 */
@Controller
@RequestMapping("redirect")
public class RedirectController {

    @GetMapping("back")
    public String redirect(@RequestHeader(value = "Referer",required = false)String referer){

        if (!StringUtils.isEmpty(referer)){
            return "redirect:"+referer;
        }else {
            return "redirect:/seckill-index.html";
        }
    }
}
